<template>
  <div class="app-container" v-if="authorityHandle(46)">
    <secondary @reset="reset" />
    <div class="filter-container">
      <span class="filter-title filter-item">饰品品质</span>
      <k-select
        v-model="listQuery.rarityId"
        class="filter-item babyquality"
        type="1"
        :custom-params="{
          opations: categoryData.qualityList,
          label: 'lineName',
          value: 'lineId',
        }"
        @handleSelectEvent="handleFilter"
      />
      <span class="filter-title filter-item">饰品外观</span>
      <k-select
        v-model="listQuery.exteriorId"
        class="filter-item babylook"
        type="1"
        :custom-params="{
          opations: categoryData.exteriorList,
          label: 'lineName',
          value: 'lineId',
        }"
        @handleSelectEvent="handleFilter"
      />

      <span class="filter-title filter-item">饰品类别</span>
      <k-select
        v-model="listQuery.qualityId"
        class="filter-item babytype"
        :custom-params="{
          opations: categoryData.typeList,
          label: 'lineName',
          value: 'lineId',
        }"
        @handleSelectEvent="handleFilter"
      />
      <span class="filter-title filter-item">饰品分类</span>
      <k-select
        v-model="listQuery.typesId"
        class="filter-item babycategory"
        :custom-params="{opations:categoryList, label:'lineName',value:'lineId'}"
        @handleSelectEvent="handleCategoryFilter"
      />
      <k-select
        v-model="listQuery.typeId"
        class="filter-item babycategory"
        :custom-params="{opations:categorySecondTypeList, label:'lineName',value:'lineId'}"
        @handleSelectEvent="handleFilter"
      />
      <k-input
        v-model.trim="listQuery.key"
        class="filter-item"
        is-search
        placeholder="饰品名称或关键词"
        :search-fun="handleFilter"
        @keyup.enter.native="handleFilter"
      />
      <!-- <span class="filter-title filter-item">兑换方式</span>
      <k-select
        v-model="listQuery.qualityId"
        class="filter-item babytype"
        :select-params="dict.type.ORNAMENT_CATEGORY"
        @handleSelectEvent="handleFilter"
      /> -->
    </div>
    <div class="top-right-btn-container">
      <k-button v-if="authorityHandle(45)" class="top-btn" value="添加饰品" @click.native="addBabyDialog" />
      <k-button v-if="authorityHandle(45)" class="top-btn" value="删除饰品" @click.native="deleteBabyDialog" />
      <!-- <k-button class="top-btn" value="玩法介绍" @click.native="ruleGuideDialog" /> -->
      <k-button class="top-right-btn" value="设置" @click.native="settingDialog" />
    </div>
    <!--表格相关 -->
    <el-table
      :data="babylist"
      fit
      highlight-current-row
      style="width: 100%;border-radius:8px;"
      :header-cell-style="{background:'#F6F5FA',color:'#4E4F62'}"
      @selection-change="handleSelectionChange"
      @sort-change="sortChange"
    >
      <el-table-column v-if="authorityHandle(45)" min-width="60px" type="selection" align="center" />
      <el-table-column width="60px" label="序号" type="index" align="center" />
      <el-table-column min-width="150px" label="图标" align="center">
        <template slot-scope="scope">
          <el-image style="width: 110px; height: 80px" :src="scope.row.iconUrl" :preview-src-list="[scope.row.iconUrl]" fit="contain" />
        </template>
      </el-table-column>
      <el-table-column prop="goodsCnName" min-width="120px" label="饰品名称" show-overflow-tooltip align="center" />
      <el-table-column label="扎比特数据" align="center">
        <el-table-column prop="zbtMinPrice" label="最低价(R)" min-width="80" sortable="custom" align="center" />
        <el-table-column prop="zbtSellNum" label="当前数量" min-width="100" sortable="custom" align="center" />
      </el-table-column>
      <el-table-column
        prop="zbtOfficialPrice"
        min-width="80px"
        label="参考价"
        sortable="custom"
        show-overflow-tooltip
        align="center"
      />

      <el-table-column
        v-if="authorityHandle(45)"
        prop="customPrice"
        min-width="120px"
        label="自定义价格(R)"
        sortable="custom"
        align="center"
      >
        <template slot-scope="scope">
          <div @click="{{changeNum(scope.$index)}}">
            <el-input
              v-if="editable[scope.$index]"
              v-model="scope.row.customPrice"
              v-focus
              @keyup.enter.native="upcustomPrice(scope)"
              @blur="blurInput(scope.$index)"
            />
            <span
              v-else
              :style="{'color':scope.row.isUpdate === 2 ? '#3b425d':'#409EFF'}"
            >{{ scope.row.customPrice }}</span>
          </div>
        </template>
      </el-table-column>

      <el-table-column
        v-else
        prop="customPrice"
        min-width="120px"
        label="自定义价格"
        sortable="custom"
        align="center"
      />

      <el-table-column
        prop="ammo"
        min-width="100px"
        label="晶粹价值"
        sortable="custom"
        show-overflow-tooltip
        align="center"
      />
      <!-- <el-table-column
        prop="price"
        min-width="100px"
        label="95币价值"
        sortable="custom"
        show-overflow-tooltip
        align="center"
      /> -->
      <el-table-column prop="typesName" min-width="100px" label="分类(父级)" show-overflow-tooltip align="center" />
      <el-table-column prop="typeName" min-width="100px" label="分类(子级)" show-overflow-tooltip align="center" />
      <el-table-column prop="rarityName" min-width="100px" label="品质" show-overflow-tooltip align="center" />
      <el-table-column prop="exteriorName" min-width="100px" label="外观" show-overflow-tooltip align="center" />
      <el-table-column prop="qualityName" min-width="100px" label="类别" show-overflow-tooltip align="center" />
      <el-table-column min-width="300px" label="饰品状态" align="center">
        <template slot-scope="scope">
          <div class="op-div">
            <el-switch
              v-model="scope.row.upStatus"
              style="display: block; margin-right:20px"
              active-color="#3b425d"
              inactive-color="#E9EBF2"
              active-text="上架"
              inactive-text="下架"
              :active-value="1"
              :inactive-value="2"
              :disabled="!authorityHandle(45)"
              @change="boxOnlineState(scope)"
            />
            <el-switch
              v-model="scope.row.hotStatus"
              style="display: block"
              active-color="#3b425d"
              inactive-color="#E9EBF2"
              active-text="热推"
              inactive-text="正常"
              :active-value="1"
              :inactive-value="2"
              :disabled="!authorityHandle(45)"
              @change="boxHostState(scope)"
            />
          </div>
        </template>
      </el-table-column>
      <el-table-column min-width="120px" label="操作" align="center">
        <template slot-scope="scope">
          <k-button :disabled="!authorityHandle(45)" class="table-btn" value="查看/修改" @click.native="updateBabyDialog(scope.row)" />
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="totalRows > 0"
      :total="totalRows"
      :page.sync="listQuery.pager.pageNo"
      :limit.sync="listQuery.pager.pageSize"
      @pagination="loadData"
    />
    <!-- 添加饰品 弹窗 -->
    <k-dialog
      :show-hide.sync="addBaby.showHide"
      :modal-append-to-body="false"
      :append-to-body="true"
      :title="textMap[dialogStatus]"
      class="addBaby-dialog"
      :two-btn="authorityHandle(45)"
      :close-fun="handleCloseDialog"
      @click="addGoodsToLuck"
    >
      <div class="el_form">
        <el-form label-width="auto">
          <el-form-item label="添加饰品：">
            <el-select
              v-model="addGoodModel.goodsId"
              :disabled="!authorityHandle(45)"
              filterable
              placeholder="请选择"
            >
              <el-option
                v-for="item in goodsResultList"
                :key="item.lineId"
                :label="item.lineName"
                :value="item.lineId"
                @click.native="selectChange(item)"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="饰品父级分类：">
            {{ typeName }}
          </el-form-item>
          <el-form-item label="饰品子级分类：">
            <el-select
              v-model="addGoodModel.type"
              :disabled="!authorityHandle(45)"
              clearable
              placeholder="请选择"
            >
              <el-option
                v-for="item in typeList"
                :key="item.id"
                :label="item.typeName"
                :value="item.id"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="自定义价格：">
            {{ customPrice }}
          </el-form-item>
          <!-- <el-form-item v-show="addGoodModel.goodsId" label="饰品兑换方式：">
            <el-select
              v-model="addGoodModel.payType"
              :disabled="!authorityHandle(45)"
              placeholder="请选择兑换方式"
              @change="payTypeChanged"
            >
              <el-option label="全晶粹兑换" :value="1" />
              <el-option label="全95币兑换" :value="2" />
              <el-option label="晶粹+95币兑换" :value="3" />
            </el-select>
          </el-form-item> -->
          <el-form-item v-show="addGoodModel.payType" label="饰品价值(J)：">
            <div style="display:flex;">
              <el-input
                v-model="addGoodModel.ammo"
                :readonly="!authorityHandle(45)"
                placeholder="请输入数值"
                :disabled="addGoodModel.payType===2"
                @input="ammoInputChange"
              />
              <span style="width:80px;margin-left:20px" v-if="JingCuiPrice">晶粹：{{JingCuiPrice}}</span>
            </div>
            <!-- <div style="display:flex;margin-top:20px">
              <el-input
                v-model="addGoodModel.price"
                :readonly="!authorityHandle(45)"
                placeholder="请输入数值"
                :disabled="addGoodModel.payType===1"
                @input="priceInputChange"
              />
              <span style="width:80px;margin-left:20px">95币</span>
            </div> -->
          </el-form-item>
        </el-form>
      </div>
    </k-dialog>
    <!-- 玩法介绍 弹窗 -->
    <k-dialog
      :show-hide.sync="ruleGuide.showHide"
      :modal-append-to-body="false"
      :append-to-body="true"
      title="玩法介绍"
      class-name="ruleGuide-dialog"
      :show-foot="false"
      :two-btn="authorityHandle(45)"
      @click="guideSave"
    >
      <div class="dialog-ruleGuide" style="padding:30px">
        <el-form :model="ruleGuideContent" label-width="auto">
          <el-form-item label="内容介绍：" prop="content">
            <quill-editor
              ref="myQuillEditor"
              v-model.trim="ruleGuideContent.content"
              :options="editorOption"
              class="editer"
            />
          </el-form-item>
        </el-form>
      </div>
    </k-dialog>

    <!-- 设置 弹窗 -->
    <k-dialog
      :show-hide.sync="setting.showHide"
      :modal-append-to-body="false"
      :append-to-body="true"
      class="setting_dialog"
      title="设置"
      :two-btn="authorityHandle(45)"
      @click="closeSettingDialog"
    >
      <el-radio-group v-model="settingType" fill="#3b425d" text-color="#ffffff" class="top-radio-group">
        <el-radio-button label="categorySetting">分类设置</el-radio-button>
        <!-- <el-radio-button label="ratioSetting">比例设置</el-radio-button> -->
      </el-radio-group>
      <div v-if="settingType === 'categorySetting'" class="setting-contanier">
        <el-form label-width="auto">
          <el-form-item label="父级分类：">
            <el-tag
              v-for="(good, index) in categoryList"
              :key="good.lineId"
              :class="{activity:activityindex == index}"
              @click="tagclick(good, index)"
            >
              {{ good.lineName }}
            </el-tag>
          </el-form-item>
          <el-form-item label="子级分类：">
            <div class="box-container">
              <el-tag
                v-for="good in categorySecondTypeList"
                :key="good.lineId"
                :closable="authorityHandle(45)"
                :disable-transitions="false"
                @close="handleGoodsTagDelete(good)"
              >
                {{ good.lineName }}
              </el-tag>
              <el-input
                v-if="authorityHandle(45) && inputVisible"
                ref="saveTagInput"
                v-model="inputValue"
                class="input-new-tag"
                size="small"
                @blur="handleInputBlur"
                @keyup.enter.native="handleInputConfirm"
              />
              <el-button
                v-if="authorityHandle(45) && !inputVisible"
                class="button-new-tag"
                size="small"
                @click="addNewItemGood"
              >
                + 添加分类
              </el-button>
            </div>
          </el-form-item>
        </el-form>
      </div>
      <!-- <div v-else class="ration_div">
        95币 =
        <el-input
          v-model="mathSettingModle.pricePercent"
          :readonly="!authorityHandle(45)"
          class="price-input"
          placeholder="请输入数值"
        />
        晶粹
      </div> -->
    </k-dialog>
  </div>
</template>

<script>
import {
  getGoodsPlatformList,
  getFirstTypeList,
  getSecondTypeListById,
  saveType,
  deleteType,
  getAmmoDescribe,
  setAmmoDescribe,
  getAmmoProp,
  setAmmoProp,
  listData,
  getMsgByGoodsId,
  getPriceMsgByGoodsId,
  addGoodsToLuck,
  deleteGoodsFromLucky,
  updateGoods,
  updateUpStatus,
  updateHotStatus
} from '@/api/bullet/index'
import {
  getCategoryQualityList,
  getCategoryExteriorList,
  getCategoryTypeList
} from "@/api/babylib/platformlib/listdata";
import {
  updateGoodsPrice
} from '@/api/babylib/platformlib/listdata'
import Pagination from '@/components/Pagination' // secondary package based on el-pagination

export default {
  components: {
    Pagination
  },
  directives: {
    focus: {
      inserted: function(el) {
        el.querySelector('input').focus()
      }
    }
  },
  dicts: ['ORNAMENT_QUALITY', 'ORNAMENT_APPEARANCE', 'ORNAMENT_CATEGORY'],
  data() {
    return {
      settingType: 'categorySetting',
      dialogStatus: 'create',
      textMap: {
        update: '修改/查看详情',
        create: '添加饰品'
      },
      activityindex: 0,
      addGoodModel: {
        goodsId: undefined,
        type: undefined,
        payType: 1,
        ammo: undefined,
        price: undefined
      },
      goodsResultList: [],
      goodsValueModel: [],
      checkedGiveBabyList: [],
      currParentId: undefined,
      typeName: '',
      customPrice: '',
      goodNameLook: '', // 查看修改显示的时候
      typeList: [],
      mathSettingModle: {
        pricePercent: undefined, // 价格差",
        minProbability: undefined, // 饰品最低概率",
        maxProbability: undefined, // 饰品最高概率",
        userPercent: undefined, // 玩家概率差值百分比",
        fissionPercent: undefined // 主播概率差值百分比"
      },
      rationCalculateModle: {
        goodsId: undefined,
        ammo: undefined, // 所需积分',
        price: undefined, // 所需金额',
        payType: 1 // 支付方式 1全晶粹|2全余额|3都有'
      },
      ruleGuideContent: {
        content: ''
      },
      editorOption: { //  富文本编辑器配置
        placeholder: '请输入内容',
        modules: {
          toolbar: [
            ['bold', 'italic', 'underline', 'strike'], // 加粗，斜体，下划线，删除线
            ['blockquote', 'code-block'], // 引用，代码块
            [{
              'header': 1
            }, {
              'header': 2
            }], // 标题，键值对的形式；1、2表示字体大小
            [{
              'list': 'ordered'
            }, {
              'list': 'bullet'
            }], // 列表
            [{
              'script': 'sub'
            }, {
              'script': 'super'
            }], // 上下标
            [{
              'indent': '-1'
            }, {
              'indent': '+1'
            }], // 缩进
            [{
              'direction': 'rtl'
            }], // 文本方向
            [{
              'size': ['small', false, 'large', 'huge']
            }], // 字体大小
            [{
              'header': [1, 2, 3, 4, 5, 6, false]
            }], // 几级标题
            [{
              'color': []
            }, {
              'background': []
            }], // 字体颜色，字体背景颜色
            [{
              'font': []
            }], // 字体
            [{
              'align': []
            }], // 对齐方式
            ['clean'], // 清除字体样式
            ['image'] // 上传图片、上传视频
          ]
        }
      },
      editable: [],
      categoryList: [],
      categorySecondTypeList: [],
      totalRows: 0, // 分页组件--数据总条数
      babylist: [], // 表格的数据
      listQuery: {
        pager: {
          pageNo: 1,
          pageSize: 10,
          totalRows: '',
          start: ''
        },
        sort: '', // 排序字段 为对应列名,
        direction: '', // 排序 正向(asc)逆向(desc),
        exteriorId: undefined, // 饰品外观',
        qualityId: undefined, // 饰品类别',
        rarityId: undefined, // 饰品品质',
        payType: 1, // 兑换',
        key: '', // 饰品名称'
        typesId: undefined, // 饰品父分类",
        typeId: undefined // 饰品子分类"
      },
      inputVisible: false,
      inputValue: '',
      babyType: 'probability',
      probility: {
        prob: ''
      },
      mathSetting: {
        showHide: false
      },
      addBaby: {
        showHide: false
      },
      ruleGuide: {
        showHide: false
      },
      setting: {
        showHide: false
      },
      multipleSelection: [],
      JingCuiPrice:0,
      categoryData:{
        qualityList:[],
        exteriorList:[],
        typeList:[]
      }
    }
  },

  created() {
    this.loadData()
    this.getFirstTypeList()
    this.getGeneralDescribe()
    this.init();
  },
  beforeDestroy() {
    localStorage.setItem('pagination', '1')
  },
  methods: {
    init(){
      this.initCategoryQualityList()
      this.initCategoryExteriorList()
      this.initCategoryTypeList()
    },
    async initCategoryQualityList(){
      const res = await getCategoryQualityList()
      if(res.status === 200){
        this.categoryData.qualityList = res.data
      }
      
    },
    async initCategoryExteriorList(){
      const res = await getCategoryExteriorList()
      if(res.status === 200){
        this.categoryData.exteriorList = res.data
      }
    },
    async initCategoryTypeList(){
      const res = await getCategoryTypeList()
      if(res.status === 200){
        this.categoryData.typeList = res.data
      }
    },
    ammoInputChange(val) {
      if (this.addGoodModel.payType !== 3 || (val.split(''))[val.length - 1] === '.') return
      this.rationCalculateModle.ammo = val
      this.rationCalculateModle.price = undefined
      this.getPriceMsgByGoodsId(this.rationCalculateModle)
    },
    priceInputChange(val) {
      if (this.addGoodModel.payType !== 3 || (val.split(''))[val.length - 1] === '.') return
      this.rationCalculateModle.ammo = undefined
      this.rationCalculateModle.price = val
      this.getPriceMsgByGoodsId(this.rationCalculateModle)
    },
    loadData(val) {
      if (val) {
        localStorage.setItem('pagination', val.page)
      }
      listData(this.listQuery).then(res => {
        const data = res.data
        this.babylist = data.rows
        this.totalRows = data.totalRows
      })
    },
    // 箱子热推
    boxHostState(scope) {
      const id = scope.row.id
      updateHotStatus({
        'id': id
      }).then(res => {
        this.$log(res)
      })
    },
    // 箱子上架
    boxOnlineState(scope) {
      const id = scope.row.id
      updateUpStatus({
        'id': id
      }).then(res => {
        this.$log(res)
      })
    },
    // 添加饰品  请求饰品
    getGoodsPlatformList() {
      getGoodsPlatformList().then(res => {
        this.goodsResultList = []
        console.log(res.data,'resdata')
        Object.assign(this.goodsResultList, res.data)
      })
    },
    // 设置 父级分类点击
    tagclick(good, index) {
      this.currParentId = good.lineId
      this.currTypeName = good.lineName
      this.activityindex = index
      this.getSecondTypeListById(this.currParentId)
    },
    // 添加新的饰品
    addNewItemGood() {
      this.inputVisible = true
      this.$nextTick((_) => {
        this.$refs.saveTagInput.$refs.input.focus()
      })
    },
    handleInputBlur() {
      this.inputVisible = false
      this.inputValue = ''
    },
    //  确定添加新的专区保存专区
    handleInputConfirm() {
      const inputValue = this.inputValue
      this.inputVisible = false
      this.inputValue = ''
      if (!inputValue) return
      const parentId = this.currParentId
      if (parentId === undefined) {
        return
      }
      saveType({
        parentId: parentId,
        typeName: inputValue
      }).then(res => {
        if (res.data.success) {
          const id = res.data.data
          const addBabyInfo = {}
          addBabyInfo.lineId = id
          addBabyInfo.lineName = inputValue
          this.categorySecondTypeList.push(addBabyInfo)
        } else {
          this.$message.error(res.data.msg)
        }
      })
    },
    // 删除饰品
    handleGoodsTagDelete(tag) {
      this.$log(tag.lineId)
      if (!tag.lineId) {
        this.$message.error('删除失败')
        return
      }
      deleteType({
        'id': tag.lineId
      }).then(res => {
        if (res.data.success) {
          this.categorySecondTypeList.splice(this.categorySecondTypeList.indexOf(tag), 1)
          this.$message.success('删除成功')
        } else {
          this.$message.warning(res.data.msg)
        }
      })
    },
    // 自定义价格
    upcustomPrice(scope) {
      const index = scope.$index
      this.blurInput(index)
      const price = scope.row.customPrice
      const id = scope.row.id
      updateGoodsPrice({
        id: id,
        customPrice: price,
        readyStatus: false
      }).then(res => {
        if (res.data.success) {
          scope.row.isUpdate = 2
        } else {
          const data = {
            show: true,
            type: 1,
            name: scope.row.goodsCnName,
            data: res.data,
            info: {
              id: id,
              customPrice: price
            }
          }
          this.$store.commit('secondary/SET_SECONDARYDATA', data)
        }
      })
    },

    // 重新获取
    reset() {
      this.loadData()
    },

    blurInput(index) {
      this.editable[index] = false
      this.$set(this.editable, index, false)
    },
    changeNum(index) {
      this.editable[index] = true
      this.$set(this.editable, index, true)
    },
    // 添加饰品 房里边的饰品选择事件
    selectChange(item){
      getMsgByGoodsId({
        'id': item.lineId
      }).then(res => {
        this.typeList = res.data.typeList
        this.typeName = res.data.typeName
        this.customPrice = res.data.customPrice
      })
      this.JingCuiPrice = item.price
      this.addGoodModel.goodsId = item.lineId
    },
    payTypeChanged(value) {
      if (value === 1) {
        this.addGoodModel.price = 0
      } else if (value === 2) {
        this.addGoodModel.ammo = 0
      }
      this.getPriceMsgByGoodsId(this.rationCalculateModle)
    },
    // 保存添加饰品
    addGoodsToLuck() {
      this.$log(this.addGoodModel)
      if (!this.addGoodModel.goodsId || !this.addGoodModel.type) {
        this.$message.error('数据出错')
        return
      }
      if ((this.addGoodModel.payType === 1 && !this.addGoodModel.ammo) || (this.addGoodModel.payType === 2 && !this.addGoodModel.price) ||
					(this.addGoodModel.payType === 3 && (!this.addGoodModel.price || !this.addGoodModel.ammo))) {
        this.$message.error('请填写晶粹或者95币')
        return
      }
      if (this.dialogStatus === 'create') {
        addGoodsToLuck(this.addGoodModel).then(res => {
          this.$message.success('保存成功')
          this.addBaby.showHide = false
          this.handleFilter()
        })
      } else {
        updateGoods(this.addGoodModel).then(res => {
          this.$message.success('修改成功')
          this.handlePageFilter()
        })
      }
      this.addBaby.showHide = false
    },
    // 获取饰品分类
    getFirstTypeList() {
      getFirstTypeList().then(res => {
        const data = res.data
        if (data.length <= 0) return
        this.categoryList = data
        this.currParentId = data[0].lineId
      })
    },
    closeSettingDialog() {
      this.setting.showHide = false
      if (this.settingType === 'ratioSetting') {
        setAmmoProp({
          data: this.mathSettingModle.pricePercent
        }).then(res => {
          this.$message.success('保存成功')
        })
      }
    },
    // 由id获取2级分类
    getSecondTypeListById(id) {
      getSecondTypeListById({
        id: id
      }).then(res => {
        this.categorySecondTypeList = []
        const data = res.data
        this.categorySecondTypeList = data
        this.$log(this.categorySecondTypeList)
      })
    },
    handleCategoryFilter(value) {
      this.handleFilter()
      this.getSecondTypeListById(value)
    },
    handlePageFilter() {
      this.listQuery.pager.pageNo = Number(localStorage.getItem('pagination')) || 1
      this.loadData()
    },
    // 搜索查询事件
    handleFilter() {
      this.listQuery.pager.pageNo = 1
      this.loadData()
    },
    // 选择项发生变化时会触发该事件
    handleSelectionChange(val) {
      this.multipleSelection = val
    },
    // 表格的排序条件发生变化的时候会触发该事件
    sortChange(column, prop, order) {
      this.listQuery.sort = column.prop
      if (column.order === 'ascending') {
        this.listQuery.direction = 'asc'
      } else if (column.order === 'descending') {
        this.listQuery.direction = 'desc'
      }
      this.loadData()
    },
    handleCloseDialog() {

    },
    updateBabyDialog(row) {
      console.log(row);
      this.dialogStatus = 'update'
      this.addBaby.showHide = true
      this.typeName = row.typeName
      this.goodNameLook = row.goodsCnName
      this.customPrice = row.customPrice
      this.addGoodModel.goodsId = row.id
      this.addGoodModel.type = row.typeId
      this.addGoodModel.payType = row.payType
      this.addGoodModel.price = row.price
      this.addGoodModel.ammo = row.ammo
      this.goodsResultList = [{
        lineId: row.id,
        lineName: this.goodNameLook
      }]
      this.selectChange({lineId:this.addGoodModel.goodsId})
    },
    addBabyDialog() {
      this.getGoodsPlatformList()
      this.getAmmoProp()
      this.dialogStatus = 'create'
      this.typeName = ''
      this.customPrice = ''
      this.typeList = []
      this.addGoodModel.goodsId = undefined
      this.addGoodModel.type = undefined
      this.addGoodModel.payType = 1
      this.addGoodModel.price = undefined
      this.addGoodModel.ammo = undefined
      this.addBaby.showHide = true
    },
    getPriceMsgByGoodsId(rationCalculateModle) {
      if (this.addGoodModel.goodsId === undefined || !this.addGoodModel.goodsId) return
      this.rationCalculateModle.goodsId = this.addGoodModel.goodsId
      this.rationCalculateModle.payType = this.addGoodModel.payType
      getPriceMsgByGoodsId(rationCalculateModle).then(res => {
        this.addGoodModel.ammo = res.data.ammo
        this.addGoodModel.price = res.data.price
      })
    },
    // 设置窗口
    settingDialog() {
      this.getAmmoProp()
      this.getSecondTypeListById(this.currParentId)
      this.setting.showHide = true
    },
    // 获取晶粹于人民币比例
    getAmmoProp() {
      getAmmoProp().then(res => {
        this.mathSettingModle.pricePercent = res.data
      })
    },
    ruleGuideDialog() {
      this.ruleGuide.showHide = true
    },
    deleteBabyDialog() {
      const _vue = this
      if (_vue.multipleSelection.length < 1) {
        this.$message.error('请至少选择一条数据进行删除！')
        return
      }
      const selections = _vue.multipleSelection
      this.$confirm('确定删除选中的饰品么?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        var ids = []
        for (var i = 0; i < selections.length; i++) {
          ids.push(selections[i].id)
        }
        deleteGoodsFromLucky({
          ids: ids
        }).then(res => {
          if (res.data.success) {
            this.$message.success('删除成功')
            this.loadData()
          } else {
            this.$message.error(res.data.msg)
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消'
        })
      })
    },
    // 保存玩法管理
    guideSave() {
      setAmmoDescribe({
        'data': this.ruleGuideContent.content
      }).then(res => {
        this.$log(res)
        this.ruleGuide.showHide = false
      })
    },
    // 加载玩法管理
    getGeneralDescribe() {
      getAmmoDescribe().then(res => {
        this.ruleGuideContent.content = res.data
      })
    }
  }
}
</script>
<style lang="scss" scoped>
	$menuText:#14162E; // 侧边栏字体颜色
	$hoverColor:#1D143C; // 鼠标停留主色调浅色
	$mainColor:#3b425d; // 主色调

	.app-container {
		padding: 30px;
	}

	.setting-contanier {
		padding: 50px;

		.box-container {
			padding: 20px;
		}

		.el-tag+.el-tag {
			margin-left: 10px;
		}

		.el-tag {
			color: $mainColor;
			background-color: #ffffff;
			border-color: $mainColor;

			::v-deep .el-tag__close {
				color: $mainColor;
			}

			::v-deep .el-icon-close:hover {
				color: #ffffff;
				background: $mainColor;
			}
		}

		.button-new-tag {
			margin-left: 10px;
			height: 32px;
			line-height: 30px;
			padding-top: 0;
			padding-bottom: 0;

			&:hover {
				color: #ffffff;
				background: $mainColor;
			}
		}

		.input-new-tag {
			width: 90px;
			margin-left: 10px;
			vertical-align: bottom;
		}

		::v-deep .el-input__inner:focus {
			border-color: $mainColor;
		}

		.activity {
			background-color: $mainColor;
			color: #ffffff;

			::v-deep .el-tag__close {
				color: #ffffff;
			}

			::v-deep .el-icon-close:hover {
				color: $mainColor;
				background: #ffffff;
			}
		}
	}

	.table-btn {
		width: 80px;
		height: 35px;
		line-height: 35px;
		padding: 0;
		background: #e7ecf8;
		border: 1px solid #3b425d;
		border-radius: 8px;
		font-size: 14px;
		color: #3b425d;

		&:hover {
			background: $mainColor;
			color: #fff;
		}
	}

	.addBaby-dialog {
		::v-deep .el-dialog__body {
			margin: 100px 100px 50px 100px;
		}

		.el_form {
			display: flex;
			flex-direction: row;
			justify-content: center;
		}
	}

	.setting_dialog {
		::v-deep .el-dialog__body {
			width: 1000px;
		}

		.ration_div {
			text-align: center;
			margin: 150px;

			.price-input {
				width: 120px;
			}
		}
	}

	.addBox-dialog {
		::v-deep .el-dialog__body {
			width: 678px;
			text-align: center;
		}

		.give_div {
			margin: 0 auto;
			padding: 50px 0px;
			height: 400px;
		}
	}

	.filter-container {
		width: 100%;
		height: 48px;
		line-height: 48px;

		.filter-item {
			display: inline-block;
			vertical-align: middle;
			margin-bottom: 10px;
		}

		.kInput {
			position: absolute;
			right: 20px;
		}

		.filter-title {
			height: 48px;
			line-height: 48px;
			font-size: 16px;
			font-weight: 500;
			margin-right: 22px;
			color: #14162E;
		}

		.babyquality {
			margin-right: 20px;
		}

		.babylook,
		.babycategory,
		.babytype {
			margin-right: 20px;
		}
	}

	.top-btn {
		margin: 30px 20px 30px 0px;
		font-size: 14px;
		color: #ffffff;
	}

	.upload-btn {
		font-size: 14px;
		color: #ffffff;
	}

	::v-deep .kSelect .el-select .el-input .el-input__inner {
		width: 150px;
	}

	.top-radio-group {
		margin-bottom: 40px;
	}

	::v-deep .el-dialog__body {
		padding: 10px 30px;
	}

	::v-deep .el-radio-button__inner {
		&:hover {
			color: $mainColor;
		}
	}

	.giveBaby-dialog {
		::v-deep .el-dialog__body {
			width: 678px;
			height: 500px;
		}

		.dialog-giveBabySetting {
			::v-deep.el-input {
				width: 200px;
			}

			.price-input {
				width: 120px;
			}
		}
	}

	.top-right-btn-container {
		position: relative;

		.top-right-btn {
			position: absolute;
			right: 20px;
			top: 30px;
			background-color: #F8F7FB;
			border-color: transparent;
			color: #14162E;

			&:hover {
				color: #ffffff;
				background-color: $mainColor;
			}

			&:active {
				color: #14162E;
			}
		}
	}

	.editer {
		width: 500px;
		border-radius: 8px;
		float: left;
		box-sizing: border-box;
		color: #606266;

		::v-deep .ql-container {
			height: 400px;
			border-radius: 0px 0px 8px 8px;
		}

		::v-deep .ql-toolbar.ql-snow {
			border-radius: 8px 8px 0px 0px;
		}
	}
</style>
